# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# Author     ：skyTree
# version    ：python 3.11
# Description：角色的schema
"""
from pydantic import BaseModel, Field
from typing import Union, List, Optional, Any
from schemas.base import DetailBaseResp


# 新增role时的参数
class RoleCreateSchema(BaseModel):
    name: str = Field(min_length=3, max_length=20, description="角色名称")
    desc: Union[str, None] = None


# 编辑role时的参数
class RoleEditSchema(BaseModel):
    id: int
    name: str = Field(min_length=3, max_length=20, description="角色名称")
    desc: Union[str, None] = None


class MenuDetailSchema(BaseModel):
    id: int
    name: str
    level: Union[int, None] = None
    path: Union[str, None] = None
    pid_id: Union[int, None] = None


# 响应时的Menu数据格式
class MenuSchema(BaseModel):
    id: int
    name: str
    level: Union[int, None] = None
    path: Union[str, None] = None
    pid_id: Union[int, None] = None
    children: Optional[List[MenuDetailSchema]] = []


class MenuTreeSchema(BaseModel):
    id: int
    name: str
    level: Union[int, None] = None
    path: Union[str, None] = None
    pid: Union[int, None] = None
    children: Optional[List[MenuSchema]] = []


# 新增role下的menu时的参数
class RoleSetOrDelPermissionSchema(BaseModel):
    id: int
    mids: List[int]


# 响应时的role数据格式
class RoleSchema(BaseModel):
    id: int
    name: str
    desc: Union[str, None] = None
    menus: Union[List[MenuTreeSchema], Any] = []


# 整个role路由函数的响应数据类型
class RoleOutSchema(DetailBaseResp):
    data: RoleSchema
